/**
 * Written by Timbot
 * V1.0, June 2007
 */
package com.as3.timbot.net
{
	import flash.events.Event;
	import flash.utils.ByteArray;
	import flash.display.Loader;
	
	import com.as3.timbot.net.AbstractLoader;
	
	public class ImageLoader extends AbstractLoader 
	{
		public function ImageLoader(_value:String, _zipped:Boolean)
		{
			super(_value, _zipped);
			
		}
		/**
		*	Calls the superclass to begin loading the asset
		*
		* 	@langversion ActionScript 3.0
		*	@playerversion Flash 9.0
		*	@tiptext
		*/
		public function load():void
		{
			super.loadAsset();
		}
		
		/**
		*	Casts the byte array received by the superclass to a particular type
		* 
		*	@param _bytes The byte array to be cast to a type
		 * 
		* 	@langversion ActionScript 3.0
		*	@playerversion Flash 9.0
		*	@tiptext
		*/
		override protected function castType(_bytes:ByteArray):void
		{
			//this function should be overridden by the sub-class for various types..variables, xml, images, swfs, id3 tags, zip files
			//an example of casting to a Display Object
			var resultImage:Loader = new Loader();
			resultImage.loadBytes(_bytes);//right now the data is a byte array....t.w.
			resultImage.contentLoaderInfo.addEventListener(Event.INIT,castFinish);
			//addChild(resultImage);//adding to the display list should happen outside of the loading process....t.w.
		}
		public function castFinish(ev:Event):void
		{
			super.castComplete(ev.target.content);
			
		}

	}
}